#include "stdafx.h"
#include "Position.h"

Position::Position(Position * root, int lh1, int rh1, int lh2, int rh2 ,CTreeCtrl * tree)
{
	parent=NULL;
	child=NULL;
	sister=NULL;
	estimation = 0;
	parent=root;

	LH[0]=lh1;
	RH[0]=rh1;
	LH[1]=lh2;
	RH[1]=rh2;

	if(tree != NULL)
	{
		if(root!=NULL)
			treetop=tree->InsertItem(Gestures[LH[0]]+Gestures[RH[0]]+"-"+Gestures[LH[1]]+Gestures[RH[1]], root->treetop);
		else
			treetop=tree->InsertItem("Root");
	}

	if(root!=NULL)
		root->NewChild(this);
}

Position::~Position(void)
{
}

void Position::DeleteTree()
{

}

void Position::NewChild(Position * child)
{
	if(this!=NULL)
	{
		if(this->child==NULL)
			this->child=child;
		else
		{
			Position * buf;
			buf=this->sister;

			while(buf!=NULL)
			{
				buf=buf->sister;
			}

			buf->sister=child;
		}
	}
}
